package com.yunxi.controller.vehicle;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.vehicle.pojo.VehicleConfigVerVO;
import com.yunxi.vehicle.service.VehicleConfigVerDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 工程配置版本明细 前端控制器
 * </p>
 *
 * @author
 * @since 2019-05-18
 */
@RestController
@RequestMapping("/admin/vehicleConfigVer")
@Api(tags = "pms:vehicleConfigVer", description = "工程配置版本明细接口")
public class VehicleConfigVerController {
    private static final Logger logger = LoggerFactory.getLogger(VehicleConfigVerController.class);

    @Autowired
    VehicleConfigVerDubboService baseVehicleConfigVerDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询分页")
    public ApiResult page(VehicleConfigVerVO vehicleConfigVerVO, @RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize) throws Exception {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.findPageByVO(vehicleConfigVerVO, pageNum, pageSize));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询分页")
    public ApiResult list(VehicleConfigVerVO vehicleConfigVerVO) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByVo(vehicleConfigVerVO));
    }

    @GetMapping("/casList")
    @ApiOperation(value = "查询分页")
    public ApiResult casList(VehicleConfigVerVO vehicleConfigVerVO) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.casList(vehicleConfigVerVO));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个")
    public ApiResult load(VehicleConfigVerVO baseVehicleConfigVerVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.getById(baseVehicleConfigVerVO.getConfigVerId()));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存信息")
    public ApiResult save(@RequestBody VehicleConfigVerVO baseVehicleConfigVerVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        baseVehicleConfigVerDubboService.saveOrUpdate(baseVehicleConfigVerVO);
        return ResponseUtil.ok("success");
    }

    @PostMapping("/del")
    @ApiOperation(value = "删除")
    public ApiResult del(@RequestBody VehicleConfigVerVO baseVehicleConfigVerVO) throws Exception {
        baseVehicleConfigVerDubboService.removeById(baseVehicleConfigVerVO.getConfigVerId());
        return ResponseUtil.ok("success");
    }

    @GetMapping("/listByColorIn")
    @ApiOperation(value = "内饰颜色查询")
    public ApiResult listByColorIn(String vehicleCode) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByColorIn(vehicleCode));
    }

    @GetMapping("/listByColorOut")
    @ApiOperation(value = "内饰颜色查询")
    public ApiResult listByColorOut(String vehicleCode) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByColorOut(vehicleCode));
    }

    @GetMapping("/listByBattary")
    @ApiOperation(value = "电池查询")
    public ApiResult listByBattary(String vehicleCode) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByBattary(vehicleCode));
    }

    @GetMapping("/listByCountry")
    @ApiOperation(value = "国家查询")
    public ApiResult listByCountry(String vehicleCode) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByCountry(vehicleCode));
    }

    @GetMapping("/listByYear")
    @ApiOperation(value = "年份查询")
    public ApiResult listByYear(String vehicleCode) {
        return ResponseUtil.ok(baseVehicleConfigVerDubboService.listByYear(vehicleCode));
    }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(baseVehicleConfigVerDubboService.findMapByList(params));
}*/
}
